<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="../../topjui/css/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="../../topjui/themes/default/topjui.blue.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="../../static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="../../static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <!-- jQuery相关引用 -->
    <script type="text/javascript" src="../../static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="../../static/plugins/jquery/jquery.cookie.js"></script>
    <!-- TopJUI框架配置 -->
    <script type="text/javascript" src="../../static/public/js/topjui.config.js"></script>
    <!-- TopJUI框架核心-->
    <script type="text/javascript" src="../../topjui/js/topjui.core.min.js"></script>
    <!-- TopJUI中文支持 -->
    <script type="text/javascript" src="../../topjui/js/locale/topjui.lang.zh_CN.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="../../static/plugins/layui/layui.js" charset="utf-8"></script>
</head>

<body>
<table data-toggle="topjui-datagrid"
       data-options="id:'productDg',
    url:'../../json/product/list.json'">
    <thead>
    <tr>
        <th data-options="field:'id',title:'ID',checkbox:true"></th>
        <th data-options="field:'name',title:'商品名称'"></th>
        <th data-options="field:'code',title:'商品编号'"></th>
        <th data-options="field:'spec',title:'规格型号'"></th>
        <th data-options="field:'danwei',title:'规格型号'"></th>
        <th data-options="field:'sale_price',title:'销售单价'"></th>
    </tr>
    </thead>
</table>

<!-- 用户 表格工具栏 -->
<div id="productDg-toolbar" class="topjui-toolbar"
     data-options="grid:{
           type:'datagrid',
           id:'productDg'
       }">
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'openDialog',
       extend:'#productDg-toolbar',
       btnCls:'topjui-btn-green',
       dialog:{
           id:'formDialog',
           href:_ctx + '/html/complex/dialog_add.html',
           height:450,
           width:700,
           buttonsGroup:[
               {text:'保存',url: _ctx + '/json/response/success.json',iconCls:'fa fa-plus',handler:'ajaxForm'}
           ]
       }">表单窗口</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="extend:'#productDg-toolbar',
       iconCls:'fa fa-pencil',
       btnCls:'topjui-btn-brown',
       onClick:myDialog">自定义窗口</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'openDialog',
       btnCls:'topjui-btn-blue',
       dialog:{
           id:'dialog1',
           href:_ctx + '/html/menu/grid.html',
           width: 1100,
           height: 600,
           buttonsGroup:[
               {text:'保存',url: _ctx + '/json/response/success.json',iconCls:'fa fa-plus',handler:'ajaxForm'}
           ]
       }">表格窗口1</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'openDialog',
       btnCls:'topjui-btn-orange',
       dialog:{
           id:'dialog2',
           href:_ctx + '/html/menu/grid.html',
           width: 1100,
           height: 600,
           buttonsGroup:[
               {text:'保存',url: _ctx + '/json/response/success.json',iconCls:'fa fa-plus',handler:'ajaxForm'}
           ]
       }">表格窗口2</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'openDialog',
       extend:'#productDg-toolbar',
       btnCls:'topjui-btn-red',
       grid:{uncheckedMsg:'请先勾选要批量提交的数据前的复选框',param:'uuid:uuid,code:code'},
       dialog:{
           id:'dialog3',
           href:_ctx + '/html/complex/dialog_add.html',
           buttonsGroup:[
               {text:'保存',url: _ctx + '/json/response/success.json',iconCls:'fa fa-plus',handler:'multiAjaxForm'}
           ]
       }">批量提交</a>
</div>
<script>
    function myDialog() {
        $('<div></div>').iDialog({
            id: 'myDialog',
            title: '自定义打开一个窗口',
            closed: false,
            height: 450,
            width: 700,
            href: _ctx + '/html/complex/dialog_add.html',
            buttons: [
                {text: '保存', iconCls: 'fa fa-plus', btnCls: 'topjui-btn-green', handler: ajaxSubmit},
                {text: '关闭', iconCls: 'fa fa-no', btnCls: 'topjui-btn-red', handler: closeMyDialog}
            ]
        })
    }
    var ajaxSubmit = function () {
        $.iMessager.alert('操作提示', '我是点击提交按钮执行的方法', 'messager-info');
    }
    var closeMyDialog = function () {
        $('#myDialog').dialog('close');
        $('#myDialog').dialog('destroy');
    }
</script>
</body>
</html>